package com.zhw.controller;

import com.zhw.pojo.PageBean;
import com.zhw.pojo.Result;
import com.zhw.pojo.dto.CustomerLossQueryDTO;
import com.zhw.pojo.entry.CustomerLoss;
import com.zhw.service.CustomerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("customerLoss")
@Slf4j
public class CustomerLossController {

    @Autowired
    CustomerService customerService;

    @GetMapping("page")
    public Result page(CustomerLossQueryDTO customerLossQueryDTO){
        log.info("客户流失分页查询：{}",customerLossQueryDTO);
        PageBean pb=customerService.getLossPage(customerLossQueryDTO);
        return Result.success(pb);
    }


    @GetMapping("getByLossByID")
    public Result getLossByID(Integer id){
        log.info("根据：{}查询流失信息",id);
        CustomerLoss customerLoss=customerService.getLossByID(id);
        return Result.success(customerLoss);
    }

    @PutMapping("checkLoss")
    public Result checkLoss(Integer id){
        log.info("确认流失客户：{}",id);
        customerService.checkLoss(id);
        return Result.success();
    }



}
